# Maintainer: Jan Alexander Steffens (heftig) <heftig@archlinux.org>

pkgname=egl-wayland
pkgver=1.1.11
pkgrel=4
epoch=2
pkgdesc="EGLStream-based Wayland external platform"
url="https://github.com/NVIDIA/egl-wayland"
arch=(x86_64)
license=(MIT)
depends=(
  eglexternalplatform
  wayland
)
makedepends=(
  git
  'libglvnd>=1.3.4'
  meson
  wayland-protocols
)
provides=(libnvidia-egl-wayland.so)
_commit=1bac4260aa89c4938246798f3a141500ed9daa10  # tags/1.1.11
source=(
  "git+$url#commit=$_commit"
  0001-Destroy-all-created-wayland-object-in-terminateDispl.patch
  0002-Fix-wrong-destruction-order-for-event-queue.patch
  10_nvidia_wayland.json
)
b2sums=('SKIP'
        'b54d31b2b086d2b9e00ca226acb47e1a7bd071d9e45af87e68c28bd6e661f009213ac92eaf6161e0c8e8b8ff91850f598c0417051c1fd90c2f5f1fa4f1f4a43b'
        '2d669bf533983616f43aa4c6aa710e27a9f1fbb53c77697709ec9d4bc25e7d99a7fb0069daa17ba690c293e581b983ae61d0140064592b75d01a8fd976cc9c66'
        'b10206c742e8966d1192b9b0604137e6b296d2be74a437841c63844c0716343578b11565a34fb4c534d5908c0b5775305581b68039a6ff9ed7421c9d385a2b7a')

pkgver() {
  cd $pkgname
  git describe --tags | sed 's/[^-]*-g/r&/;s/-/+/g'
}

prepare() {
  cd $pkgname

  # https://bugs.archlinux.org/task/77260
  # https://github.com/NVIDIA/egl-wayland/pull/74
  git apply -3 ../0001-Destroy-all-created-wayland-object-in-terminateDispl.patch

  # https://bugs.archlinux.org/task/78143
  # https://github.com/NVIDIA/egl-wayland/pull/79
  git apply -3 ../0002-Fix-wrong-destruction-order-for-event-queue.patch
}

build() {
  arch-meson $pkgname build
  meson compile -C build
}

check() {
  meson test -C build --print-errorlogs
}

package() {
  meson install -C build --destdir "$pkgdir"
  install -Dt "$pkgdir/usr/share/egl/egl_external_platform.d" -m644 10_nvidia_wayland.json
  install -Dt "$pkgdir/usr/share/licenses/$pkgname" -m644 $pkgname/COPYING
}

# vim:set sw=2 sts=-1 et:
